{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2757ea59",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.21.0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(2, 2, 3, 2)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "print(np.__version__)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e2932cc0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2]\n",
      "[[1 2 3]]\n",
      "[[1]\n",
      " [2]\n",
      " [3]]\n"
     ]
    }
   ],
   "source": [
    "a1 = np.array([1, 2])  # 一维数组\n",
    "print(a1)\n",
    "\n",
    "a2 = np.array([[1, 2, 3]])\n",
    "print(a2)\n",
    "\n",
    "a3 = np.array([[1], [2], [3]])\n",
    "print(a3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "055755da",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 2 3 4]\n",
      " [2 4 2 4]]\n",
      "2\n",
      "(2, 4)\n",
      "[3 6 5 8]\n",
      "[10 12]\n"
     ]
    }
   ],
   "source": [
    "a3 = np.array(\n",
    "    [\n",
    "        [1, 2, 3, 4],\n",
    "        [2, 4, 2, 4]\n",
    "    ]\n",
    ")\n",
    "\n",
    "print(a3)\n",
    "\n",
    "print(a3.ndim)\n",
    "\n",
    "print(a3.shape)\n",
    "\n",
    "print(a3.sum(0))\n",
    "\n",
    "print(a3.sum(1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "842d2798",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2, 2, 4)\n",
      "[[ 1  3  5  7]\n",
      " [ 9 11 13 15]]\n",
      "[[ 4  6  8 10]\n",
      " [ 6  8 10 12]]\n",
      "[[ 6 22]\n",
      " [10 26]]\n"
     ]
    }
   ],
   "source": [
    "c = np.array(\n",
    "    [\n",
    "        [\n",
    "            [0, 1, 2, 3],\n",
    "            [4, 5, 6, 7]\n",
    "        ],\n",
    "        [\n",
    "            [1, 2, 3, 4],\n",
    "            [5, 6, 7, 8]\n",
    "        ]\n",
    "    ])\n",
    "\n",
    "\n",
    "print(c.shape)\n",
    "\n",
    "print(c.sum(axis=0))\n",
    "\n",
    "print(c.sum(axis=1))\n",
    "\n",
    "print(c.sum(axis=2))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
